<?php
class detection
{
   	//获取IP
	function g_ip($add)
	{	
		//$add ='www.baidu.com';
		if($a = gethostbyname($add))
		{
			return $a;
		}
		else 
		{
			return 'this ip is not find';
		}        
	}
	
	function ping($to_ping)
	{
		exec("ping  $to_ping", $list);
		if(strstr($list[0],"not"))
        {
            $ii = 'the domain is not find';
            return $ii;
        }
        else
        {        	
			$b=explode(" ",$list[11]);                
			$a = array
			(
				"Minimum" => preg_replace('/[^0-9]/','',$b[6]),
				"Maximum" => preg_replace('/[^0-9]/','',$b[9]),
				"Average" => preg_replace('/[^0-9]/','',$b[12]),
			);
 	       return $a;
        }
	}
}